﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Background;

namespace BackgroundAgant
{

    public sealed class cnBlogsBackgroundTask : IBackgroundTask
    {

        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();
            var feed = await GetFeed();
            UpdateTile(feed);
            _deferral.Complete();

        }

        private static async Task<List<ArticleInfo>> GetFeed()
        {
            MainPageViewModel_lightWeight mainPageVewModel = new MainPageViewModel_lightWeight();
            await mainPageVewModel.GetResource();
            return mainPageVewModel.ArticleInfoList;
        }
        private void UpdateTile(List<ArticleInfo> articleInfo)
        {
            TileHelper.AddTile(articleInfo);
        }
    }


}
